package com.pdg.mcplugin.tsa;

import java.util.HashSet;
import java.util.Set;

import org.bukkit.Material;

import com.pdg.mcplugin.common.baseclasses.PluginClientBase;

public class ContrabandList extends PluginClientBase<TSA>{
	private ContrabandManager contrabandManager;
	private Set<Material> materials = new HashSet<Material>();
	
	public ContrabandList(ContrabandManager theContrabandManager){
		super(theContrabandManager.getPlugin());
		setContrabandManager(theContrabandManager);
	}

	public ContrabandManager getContrabandManager() {
		return contrabandManager;
	}

	private void setContrabandManager(ContrabandManager contrabandManager) {
		this.contrabandManager = contrabandManager;
	}
	
	public String getName(){
		return getContrabandManager().findContrabandList(this);
	}
	
	public void commit() {
		// TODO Auto-generated method stub
	}


	public boolean add(Material theMaterial, boolean commit) {
		if(!has(theMaterial)){
			materials.add(theMaterial);
			if(commit) commit();
			return true;
		}else{
			return false;
		}
	}

	public boolean add(Material theMaterial) {
		return add(theMaterial,true);
	}
	
	public boolean remove(Material theMaterial, boolean commit){
		if(has(theMaterial)){
			materials.remove(theMaterial);
			if(commit) commit();
			return true;
		}else{
			return false;
		}
	}
	
	public boolean remove(Material theMaterial){
		return remove(theMaterial,true);
	}
	
	public boolean has(Material theMaterial){
		return materials.contains(theMaterial);
	}
}
